package com.xinzhi.controller;

import com.xinzhi.entity.Result;
import com.xinzhi.service.CartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

@Controller
@RequestMapping("/cart")
@ResponseBody
public class CartController {
    @Autowired
    private CartService cartService;
    @RequestMapping("/addProduct")
    public Result addCart(String productId,HttpServletRequest httpServletRequest){
        return cartService.addProduct(productId,httpServletRequest);
    }

    @RequestMapping("/checkCart")
    public Result subtractProduct(HttpServletRequest httpServletRequest){
        return cartService.checkCart(httpServletRequest);
    }

    @RequestMapping("/subtractProduct")
    public Result subtractProduct(String productId,HttpServletRequest httpServletRequest){
        return cartService.subtractProduct(productId,httpServletRequest);
    }

    @RequestMapping("/plusProduct")
    public Result plusProduct(String productId,HttpServletRequest httpServletRequest){
        return cartService.plusProduct(productId,httpServletRequest);
    }

    @RequestMapping("/deleteProduct")
    public Result deleteProduct(String productId,HttpServletRequest httpServletRequest){
        return cartService.deleteProduct(productId,httpServletRequest);
    }

}
